home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap12 / dun12_4.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  691 b   |  32 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE>scripting position - communicator</TITLE>
  4. </HEAD>
  5. <SCRIPT LANGUAGE="JavaScript">
  6. function random (limit)
  7.     {
  8.      return (Math.round(((Math.random())*1000))%limit)+1;
  9.     }
  10. function moveElement()
  11.     {
  12.     document.layers['movingElement'].left=random(300);
  13.     document.layers['movingElement'].top=random(300);
  14.     }
  15. </SCRIPT>
  16. <STYLE TYPE="text/css">
  17. .comeAlong{
  18.     POSITION: absolute;
  19.     TOP: 100px;
  20.     LEFT: 100px;
  21.     }
  22. </STYLE>
  23. <BODY BGCOLOR="#ffffff">
  24.  
  25. <DIV ID="movingElement" CLASS="comeAlong">
  26. <FORM>
  27. <INPUT TYPE=BUTTON VALUE="you move me" ONCLICK="moveElement()">
  28. </FORM>
  29. </DIV>
  30. </BODY>
  31. </HTML>
  32.